<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var year = Number(prompt('输入年份'))
    var month = Number(prompt('输入月份'))
    switch (month) {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
        console.log(31)
      break;
      case 4:
      case 6:
      case 9:
      case 11:
        console.log(30)
      break;
      case 2:
        // 判断润平年
        if (year % 4 === 0 && year % 100 != 0 || year % 400 === 0) {
          console.log(29)
        } else {
          console.log(28)
        }
      break;
      default: 
        console.log('请输入1-12')
    }
  </script>
</body>
</html>